package com.example.Controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.example.Service.impl.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {
    private static final Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private LogService logService;

    @GetMapping("/log")
    public String logMessage() {
        String msg = "This is a sample log message.";
        logger.info(msg);
        logService.log("INFO", "LoggingController", msg);
        return "Log message sent to database!";
    }

}
